//
//  MyCardCell.m
//  WanCaiC8
//
//  Created by tangang on 2018/3/20.
//  Copyright © 2018年 tangang. All rights reserved.
//

#import "MyCardCell.h"

@implementation MyCardCell{
    UIImageView     *bgImageV;
    UIImageView     *lookImage;
    QXLable         *labTime;
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self=[super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        WS(weakSelf);
        self.contentView.backgroundColor=DEFAULTBGCOLOR;
        
        bgImageV   =[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"effective"]];
        [self.contentView addSubview:bgImageV];
        [bgImageV mas_makeConstraints:^(MASConstraintMaker *make) {
            make.center.equalTo(weakSelf.contentView);
            make.size.mas_equalTo(CGSizeMake(SCREEN_WIDTH-20, bgImageV.image.size.height/(bgImageV.image.size.width/(SCREEN_WIDTH-20))));
        }];
        
        lookImage =[[UIImageView alloc]initWithImage:[UIImage imageNamed:@"lookCard"]];
        [self.contentView addSubview:lookImage];
        [lookImage mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(bgImageV).with.offset(30);
            make.top.equalTo(bgImageV).with.offset(21);
            make.size.mas_equalTo(CGSizeMake(48, 43.5));
        }];
        
        labTime =[[QXLable alloc]initWithFount:10];
        NSMutableAttributedString *attstr=[[NSMutableAttributedString alloc]initWithString:@"查看券\n\n有效期至：2018.03.16 11:05-2018.03.17 11:15"];
        [attstr addAttribute:NSForegroundColorAttributeName value:DEFAULTTEXTGDARKRAYCOLOR range:NSMakeRange(0, 3)];
        [attstr addAttribute:NSFontAttributeName value:[UIFont systemFontOfSize:18] range:NSMakeRange(0, 3)];
        labTime.attributedText=attstr;
        [self.contentView addSubview:labTime];
        [labTime mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(lookImage.mas_right).with.offset(19);
            make.centerY.equalTo(lookImage);
            make.size.mas_equalTo(CGSizeMake(250, 60));
        }];
        
        QXLable *labPrompt=[[QXLable alloc]initWithFount:10];
        labPrompt.textColor=DEFAULTTEXTGDARKRAYCOLOR;
        labPrompt.textAlignment=NSTextAlignmentCenter;
        labPrompt.text=@"查看券来源于新用户注册成功可获取1张查看券，查看券当天有效，过期无效";
        [self.contentView addSubview:labPrompt];
        [labPrompt mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.right.bottom.equalTo(bgImageV);
            make.height.mas_equalTo(@30);
        }];
    }
    return self;
}

- (void)setStatus:(NSInteger)status{
    if (status==0) {
        bgImageV.image=[UIImage imageNamed:@"effective"];
    }else if (status==1){
        bgImageV.image=[UIImage imageNamed:@"effective_use"];
    }else if (status==2){
        bgImageV.image=[UIImage imageNamed:@"effective_over"];
    }
}

@end
